package JAVAcollectionsanddatastructures.Reflect;

class Student {
    //私有属性name
    private String name = "TC";
    //公有属性age
    public int age = 19;
    //不带参数的构造方法
    public Student(){
        System.out.println("Student()");
    }

    private Student(String name,int age) {
        this.name = name;
        this.age = age;
        System.out.println("Student(String,name)");
    }

    private void eat(){
        System.out.println("i am eat");
    }

    public void sleep(){
        System.out.println("i am pig");
    }

    private void function(String str) {
        System.out.println(str);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
public class TestDemo1 {
    public static void main(String[] args) throws ClassNotFoundException {
        //注意这里是类的全路径，如果有包需要加包的路径
        Class<?> c1 = Class.forName("JAVAcollectionsanddatastructures.Reflect.Student");

        //.直接通过 类名.class 的方式得到,该方法最为安全可靠，程序性能更高
        //这说明任何一个类都有一个隐含的静态成员变量 class
        Class<?> c2 = Student.class;

        Student student = new Student();
        Class<?> c3 = student.getClass();


//一个类在 JVM 中只会有一个 Class 实例,即我们对上面获取的
        System.out.println(c1==c2);
        System.out.println(c1==c3);
        System.out.println(c2==c3);
    }
}
